﻿<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="../../lib/layui/layui.js"></script>
    <link href="../../css/font.css" rel="stylesheet" />
    <link href="../../css/xadmin.css" rel="stylesheet" />
    <script src="../../js/jquery-3.2.1.min.js"></script>
    <script src="../js/xadmin.js"></script>
    <script src="../js/public.js"></script>
    <script src="../../js/xadmin.js"></script>
    <script src="../js/cookie.js"></script>
</head>
<body>
    <div class="x-body">
        <form class="layui-form">

             <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>账号
                </label>
                <div class="layui-input-inline">
                    <input type="" id="account" lay-verify="required"  autocomplete="off" class="layui-input" >
                </div>
         
            </div>
            <%--//密码--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>新密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="password" lay-verify="pass"  autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
            </div>
            <%--//确认密码--%>
            <div class="layui-form-item">
               <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>确认新密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="secpassword" lay-verify="pass"  autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">再输入一次刚才输入的密码</div>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    修改
                </button>
            </div>

            <script>
                layui.use('form', function () {
                    var form = layui.form;
                    //各种基于事件的操作，下面会有进一步介绍
                    form.on('submit(add)', function (data) {
                        layer.confirm('确认修改密码？', {
                            btn: ['确定', '放弃'] //按钮
                        }, function () {
                            //Ajax上传逻辑
                            //第一个匿名函数是第一个按钮的回调function
                            sumitNew();
                        }, function () {
                            //取消操作，弹出取消，不清除form表单里的信息
                        });
                        return false;
                    });

                });
                function sumitNew() {
                    var emp = new Object();
                    emp.account = $("#account").val();
                    console.log(emp.account)
                    emp.password = ($("#password").val());
                    emp.secpassword = ($("#secpassword").val());

                    if (emp.password == emp.secpassword) {
                        myAjax("UserHandler.ashx", "UpdatePwd", emp, false, function (data) {
                            //提示层
                            console.log(data);
                            if (data.Code == 1) {
                                layer.msg('修改成功');
                                self.location.href = "./Login.aspx";
                            } else if (data.Code == 2) {
                                layer.alert('账号“' + emp.account + '”不存在', {
                                    skin: 'layui-layer-molv' //样式类名
                                    , closeBtn: 0
                                    //动画类型
                                });
                            }

                        }, function () {
                            layer.alert('发生了一些预期之外的错误');
                        });
                    }
                    else {
                        layer.alert('两次密码不一致')
                        return false;
                    }  
                }
            </script>
        </form>
    </div>
</body>
</html>
